
import requests
from bs4 import BeautifulSoup


headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
}

url = "http://quote.stockstar.com/fund/stock.shtml"

response = requests.get(url, headers=headers)
# print(response.text)

# 处理数据
soup = BeautifulSoup(response.content.decode('gb2312'), 'lxml')

tr_list = soup.select('#datalist > tr')

for tr in tr_list:
    s_id = tr.select('td')[0].a.text  # 基金代码
    s_name = tr.select('td')[1].a.text  # 基金简称
    s_value = tr.select('td')[3].text  # 累计净值

    print(s_id, s_name, s_value)